package com.company.cloud.art.client;

import com.company.cloud.art.modules.api.request.*;
import com.company.cloud.art.modules.api.response.ActSignUp;

import com.company.cloud.art.modules.api.response.ActSignUpQueryResp;
import com.company.cloud.art.modules.api.response.ArtAct;
import com.company.cloud.art.modules.api.response.ArtActQueryResp;
import com.company.cloud.art.modules.api.service.ArtActRemoteService;
import com.company.cloud.art.modules.mgr.service.ActActivityMgrService;
import com.company.cloud.common.bean.BaseClientResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.common.exception.BusinessException;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Log4j2
@RestController
@Service
public class ArtActRemoteServiceImpl implements ArtActRemoteService {

    @Autowired
    private ActActivityMgrService actActivityMgrService;

    @Override
    public BaseClientResult<ActSignUpQueryResp> actSignUpQuery(ActSignUpQueryReq request) {
        try {
            return BaseClientResult.success(actActivityMgrService.actSignUpQuery(request));
        }catch (Exception e){
            return BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> actSignUpAdd(ActSignUpAddReq request){
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actActivityMgrService.actSignUpAdd(request,userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }

    }

    @Override
    public BaseClientResult<ActSignUp> actSignUpInfo(Integer id) {
        try {
            return BaseClientResult.success(actActivityMgrService.actSignUpInfo(id));
        }catch (Exception e){
            return BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<ArtActQueryResp> actQuery(ArtActQueryReq request) {
        try {
            return BaseClientResult.success(actActivityMgrService.actQuery(request));
        }catch (Exception e){
            return BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<ArtAct> actInfo(String activityNo) {
        try {
            return BaseClientResult.success(actActivityMgrService.actInfo(activityNo));
        }catch (Exception e){
            return BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> actAdd(ArtActSaveReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actActivityMgrService.actAdd(request,userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }

    }

    @Override
    public BaseClientResult<String> actUpdate(ArtActUpdateReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actActivityMgrService.actUpdate(request,userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> actDel(ArtActDelReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actActivityMgrService.actDel(request.getActivityNo(),userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }
}
